Repository navigation
[feat] canvas: keep one shortcut list for hints, help and keys - #501
Zhangbo-cn wants to merge 14 commits into
Conversation
7f7407e to
20bfd31
Compare
|
First CI run went red on Cause was mine, not flaky: the new Re-verified after the fix: |
f8350ca to
eba5454
Compare
Each panel owned its own copy of the shortcuts: the workspace help dialog listed them by hand, tooltips hardcoded strings like "⌘ ⇧ G", aria-keyshortcuts repeated them again, and four separate keydown listeners decided what the keys did. The copies had already drifted -- the help dialog advertised Ctrl+, for the model settings while the handler listened for a different key, so the shortcut did nothing while the tooltip promised it worked.
src/canvas/shortcuts.ts is now the one table: a combo, its macOS and Windows spellings, and the event names it matches. Tooltips, the help dialog, aria-keyshortcuts and the app-wide handler all read from it, and a unit test fails if a registered combo has no platform spelling or if a handler matches a key the table does not list. One window listener replaces the four: it ignores keys typed into a field or pressed while a dialog is open, so Escape and typing behave as before.
The comma mapping is spelled out rather than derived: the registry names the key "comma" while KeyboardEvent.key is ",". Deriving it is what produced the tooltip that promised a shortcut nobody had wired.
docs/architecture/desktop{,.zh-CN}.md records why the page owns these keys: the packaged Windows build has no menu accelerators, so Ctrl+N, Ctrl+K and Ctrl+J reach the renderer directly, and giving the menu accelerators as well would fire each of them twice.
eba5454 to
a765e2c
Compare
|
Rebased onto Two conflicts, both in
Worth stating because the plain-text resolution would have been wrong: dropping Ran: |
|
PASS a765e2c
Ran: |
Co-Authored-By: Claude Code <noreply@anthropic.com>
The assistant composer is focused when the app opens, and the hook treated any focused input or contenteditable as a reason to ignore Ctrl+N, Ctrl+K, Ctrl+, and Ctrl+J. Those combos all carry a modifier and have no typed meaning, so only an open dialog and IME composition keep their keys now. The browser test covers Ctrl+N and Ctrl+J from the focused composer, and shows that typed text still reaches the project search field. Co-Authored-By: Claude Code <noreply@anthropic.com>
The app-wide shortcut handler replaced the desktop sidebar's own keydown listener but routed Ctrl+K to the project picker everywhere, so the packaged app lost its sidebar search and the desktop smoke failed. Keep the picker in the browser and open the sidebar search when the desktop shell is present. Co-Authored-By: Claude Code <noreply@anthropic.com>
The browser lane now mounts the workspace with the desktop-shell globals and asserts the key opens the sidebar search instead of the project picker. At 839412f that assertion fails, which is the failure the packaged smoke reported on both desktop lanes. Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
The composer dropped every keydown except Escape before it reached the window shortcut listener, so settings, project switching, and the assistant toggle did nothing while the cursor sat in the text field. Let the four app shortcuts bubble and press them for real from the composer in the browser test. Co-Authored-By: Claude Code <noreply@anthropic.com>
…e composer Co-Authored-By: Claude Code <noreply@anthropic.com>
The shortcut registry now owns the sidebar search hint; the toggle had dropped its aria-keyshortcuts and title suffix while the sidebar's own listener owned Ctrl+K. Derive both from the registry again and pin the attribute in the desktop browser case. Co-Authored-By: Claude Code <noreply@anthropic.com>
Recaptured both locales with real key presses from the focused chat composer after the head added the sidebar search hint. Co-Authored-By: Claude Code <noreply@anthropic.com>
Record the desktop sidebar search opened by a real Ctrl+K, with the shortcut attribute the head restores. Co-Authored-By: Claude Code <noreply@anthropic.com>
Register, hint, and list new-project/switch-project/settings/assistant only when the document carries data-desktop-chrome; browsers keep Ctrl+N/K/J. Derive the handler map from the narrowed APP_SHORTCUTS list, refocus an already-open Ctrl+K search, and keep Ctrl+N off while renaming. Register the test modules main left out of the shard manifest.
# Conflicts: # scripts/ci/python_shards.json
|
Conflicts with Internal audit score: 95/100. @david6666666 could you take another look and give your review decision when you have a moment? |
david6666666
left a comment
There was a problem hiding this comment.
WITHHOLD ac4e136 No linked issue
把 app shortcut 的显示和 handler 用同一张表维护,方向对。我下载看了两张帮助页,Web/desktop 的提示确实分开;但截图证明不了实体 Electron 窗口按键只触发一次,也看不出从帮助到实际动作的流程。Release 已绿,补一段 desktop 的可播放录屏(至少 Ctrl+, 和 Ctrl+N;能附 macOS Cmd+, 更好),再给通过结论。
Ran: 回读同 SHA Release及本 PR 的变更与证据。Not run: 未独立执行 PR 代码或调用真实 provider。
63/100(范围/正确性/验证/主张证据/简洁度:3/3/2/0/3)。
Base 322f98c317322c1ac12541093719c890507b51b0 · Head ac4e13660689e219e499733c4e22f57d404dab74。
Dot,代表 @david6666666。
|
@david6666666 the desktop recording you asked for is on It is a 14 s capture of a real Electron 45.3.3 window built from Harness details and limitations are in the PR body: WSLg window capture via X11 |
david6666666
left a comment
There was a problem hiding this comment.
PASS ac4e136 No linked issue
LGTM。下载并核对了 14.6 秒 Electron 录屏:Ctrl+, 和 Meta+, 都打开 Settings,Ctrl+N 后新增项目出现在桌面侧栏。它是在 WSLg 的真实 Electron 窗口里套用 desktop preload 契约,不是 macOS 实机;同 SHA 的 macOS/Windows Release 已绿。main 新增的是 Composer 素材枚举,和快捷键注册路径分开。无可执行的新问题。
Ran: 核对同 SHA Release、变更并下载查看作者录屏。Not run: 未独立运行 PR 代码或真实 provider。
93/100(范围/正确性/验证/主张证据/简洁度:3/3/2/3/3)。
Base 322f98c317322c1ac12541093719c890507b51b0 · Head ac4e13660689e219e499733c4e22f57d404dab74。
Dot acting for @david6666666 under delegated independent OpenDirector PR review.
Coordinator: 交由仓库指定集成人处理;未执行合入。
What
Shortcuts were declared five times: the workspace help dialog listed them by hand, tooltips hardcoded strings like
⌘ ⇧ G,aria-keyshortcutsrepeated them again, and four separatekeydownlisteners decided what the keys did. The copies had already drifted. The help dialog advertisedCtrl+,for model settings while the handler listened for a different key, so the shortcut did nothing while the tooltip promised it worked — reported as "it showsCtrl+,but the key does not fire".src/canvas/shortcuts.tsis now the single table: a combo, its macOS and Windows spellings, and theKeyboardEvent.keynames it matches. Tooltips, the help dialog,aria-keyshortcutsand the app-wide handler all derive from it. Onewindowlistener replaces the four.Application shortcuts belong to the desktop shell.
new-project,switch-project,settingsandassistantare registered, hinted, listed in the help dialog, and shown inaria-keyshortcutsonly when the document carriesdata-desktop-chrome. In a normal browserCtrl+N,Ctrl+KandCtrl+Jare the browser's own (new window, address bar, downloads); the page cannot receive them reliably, so it neither handles nor advertises them. Editor and canvas shortcuts (Ctrl+Z,Ctrl+A,T, …) are unchanged on the web.The handler map is typed
Record<AppShortcutId, () => void>, withAppShortcutIdnarrowed fromAPP_SHORTCUTS as const. Adding an id to the list without a handler is a type error instead of a silently ignored key.The listener ignores keys typed while composing, repeated presses, modifier combinations that do not match the table, and presses while a dialog is open.
Ctrl+Krefocuses an already-open sidebar search instead of leaving focus behind, andCtrl+Nis disabled while the project is switching or its name is being committed, matching the old listener's guard.The
comma → ","mapping is explicit rather than derived. Deriving the key name from the combo name is what produced a tooltip promising a shortcut nobody had wired.docs/architecture/desktop{,.zh-CN}.mdnow records why the shell needs no menu accelerators: the packaged Windows build has no menu shortcut table, soCtrl+N,Ctrl+KandCtrl+Jreach the renderer directly, and adding menu accelerators (or an IPC forward) as well would fire each shortcut twice. That was measured on real Windows, not assumed — an earlier version of this branch did callsetApplicationMenuwith accelerators and double-triggered.Verification
tests/browser/shortcuts.mjs(gate lane, isolated fixture, headless Chrome): on the web page the settings tooltip has nokbd, the project trigger and create menu have noaria-keyshortcuts/kbd, the help dialog omits the app rows, andCtrl+,/Ctrl+K/Ctrl+N/Ctrl+Jneither prevent default nor open settings, the picker, a project, or the assistant. In a desktop-marked context the same keys work:Ctrl+Kopens the sidebar search and refocuses it when pressed again,Ctrl+Ncreates one project, and the help dialog lists all four app rows.tests/shortcutHints.test.ts(new): displayed keys match the keys the handlers listen for; every help row has a label and hint; app rows are absent withoutdata-desktop-chromeand present with it.npx tsc --noEmitclean;npm test1120 pass / 0 fail;scripts/ci/python_shards.jsongains the three modulesmainleft unregistered (test_ark_availability.py,test_trace_job_queries.py,test_wait_outcome.py) andpytest tests/test_ci_layers.pyis 21 passed.apps/desktopis untouched: the probe showed the Electron build needs no menu handling, so none was added.Evidence
Captured from the isolated fixture at
12cd7e26, the feature tip.ac4e1366mergesorigin/mainat322f98c3to resolve the shard-manifest conflict and does not change the registry or the help dialog; Release checks are green onac4e1366. Without a desktop shell the help dialog lists only editor and canvas shortcuts; in a desktop-marked document it also listsCtrl+N,Ctrl+K,Ctrl+,andCtrl+J.data-desktop-chrome)data-desktop-chrome)Corrections from review
Ctrl+N/K/J; it now asserts the opposite, and the help copy and PR text follow.openSignal/projectPickerRequestpath and the web branch of the switch-project handler are removed; the sidebar search no longer needs a parent-driven open signal.Desktop shell recording
Recorded with
electron@45.3.3fromapps/desktop/node_modulesand a minimalBrowserWindowharness (the productionmain.mjsexpects a prepared runtime manifest), loading the same Vite renderer against the isolated creation fixture on Linux/WSLg.Play the 14 s recording
Ctrl+,opens Settings on General.Meta+,— theevent.metaKeya macOSCmd+,sends — opens the same dialog through the sharedmodmatcher.Ctrl+Ncreates exactly one project: the fixture's project list is read immediately before and after the keypress, and the recording ends on the new project (Untitled project 5) selected in the desktop sidebar.Harness notes: window contents are captured with X11
-window_id(WSLg's compositor does not expose the full desktop tox11grab), and the harness preload mirrors the shell contract thatapps/desktop/src/preload.cjsinstalls on darwin/win32 (data-desktop-chrome,window.opendirectorDesktop); the Linux build intentionally leavesdata-desktop-chromeoff. There is no macOS host in this environment, so the macOS caption/darwin CSS path itself is not exercised;Meta+,covers the samematchesShortcutbranch. No product code changed afterac4e1366; Release checks are green on this head.